@extends("admin.layout.main")

@section("content")
    <style>
        .error {
            color: red;
        }
    </style>

    <!--主页面头部信息-->
    <div class="page-header">
        <h1>
            资金调节
        </h1>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <form class="form-horizontal" method="post" id="form" action="{{ route('admin.member.ajaxSaveEditCash') }}">
                <input type="hidden" name="user_id" value="{{ $userInfo->id }}">
                <div class="form-group">
                    <label class="col-sm-1 control-label no-padding-right"> 会员姓名: </label>
                    <div class="col-sm-9" style="margin-top: 9px">
                        {{ $userInfo->name }}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label no-padding-right"> 积分: </label>
                    <div class="col-sm-9">
                        <select name="integral_type" style="height: 34px" onchange="checkInteNumber()">
                            <option value="1">增加</option>
                            <option value="2">减少</option>
                        </select>
                        <input placeholder="" name="integral_number" number="true" type="text" onchange="checkInteNumber()">
                        可用积分：{{ $userInfo->integral }}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label no-padding-right"> 注册币: </label>
                    <div class="col-sm-9">
                        <select name="coin_type" style="height: 34px" onchange="checkCoinNumber()">
                            <option value="1">增加</option>
                            <option value="2">减少</option>
                        </select>
                        <input placeholder="" name="coin_number" number="true" type="text" onchange="checkCoinNumber()">
                        可用注册币：{{ $userInfo->registered_currency }}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label no-padding-right"> 操作备注: </label>
                    <div class="col-sm-9">
                        <textarea style="resize: none;width: 400px;height: 300px;" name="reasons" maxlength="50" required></textarea>
                    </div>
                </div>
                <div class="col-md-offset-2 col-md-9">
                    <button class="btn btn-info btn-primary">
                        保存
                    </button>
                    <a class="btn" onclick="javascript:history.back(-1);">
                        取消
                    </a>
                </div>
            </form>
        </div>
    </div>
    <script src="{{ config('global.assets_path') }}js/jquery.validate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/messages_zh.js"></script>
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/layui/layui_component.js"></script>
    <script src="/js/ajax.js"></script>
    <script>
        function checkInteNumber() {
            var type = $('select[name="integral_type"]').val();
            var number = $('input[name="integral_number"]').val();
            var cash = '{{ $userInfo->integral }}';
            if(type == 2 && number > cash){
                $('input[name="integral_number"]').attr('max',parseFloat(cash));
            }else{
                $('input[name="integral_number"]').removeAttr('max');
            }
        }
        function checkCoinNumber() {
            var type = $('select[name="coin_type"]').val();
            var number = $('input[name="coin_number"]').val();
            var cash = '{{ $userInfo->registered_currency }}';
            if(type == 2 && number > cash){
                $('input[name="coin_number"]').attr('max',parseFloat(cash));
            }else{
                $('input[name="coin_number"]').removeAttr('max');
            }
        }
    </script>
@endsection
